package com.bwie.config;

import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import reactor.core.publisher.Mono;

/**
 * @author lenovo
 */
@Configuration
public class GatewayConfig {

    /**
     * @description:网关配置限流
     * @author: sxting~😊
     * @Date: 2024/9/9 9:40
     * @param:
     * @return: org.springframework.cloud.gateway.filter.ratelimit.KeyResolver
    **/
    @Bean
    public KeyResolver ipKeyResolver(){
        return exchange -> Mono.just(exchange.getRequest().getRemoteAddress().getHostName());
    }
}
